/*******************************************************************************************/
/* The MIT License (MIT)                                                                   */
/*                                                                                         */
/* Copyright (c) 2014 - Marina High School FIRST Robotics Team 4276 (Huntington Beach, CA) */
/*                                                                                         */
/* Permission is hereby granted, free of charge, to any person obtaining a copy            */
/* of this software and associated documentation files (the "Software"), to deal           */
/* in the Software without restriction, including without limitation the rights            */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell               */
/* copies of the Software, and to permit persons to whom the Software is                   */
/* furnished to do so, subject to the following conditions:                                */
/*                                                                                         */
/* The above copyright notice and this permission notice shall be included in              */
/* all copies or substantial portions of the Software.                                     */
/*                                                                                         */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR              */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,                */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE             */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER                  */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,           */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN               */
/* THE SOFTWARE.                                                                           */
/*******************************************************************************************/

/*******************************************************************************************/
/* We are a high school robotics team and always in need of financial support.             */
/* If you use this software for commercial purposes please return the favor and donate     */
/* (tax free) to "Marina High School Educational Foundation"  (Huntington Beach, CA)       */
/*******************************************************************************************/

#include <string>
#include <stdio.h>
#include "CLedStrip.h"
#include "dbgMsg.h"

CLedStrip::CLedStrip()
{
    m_ledStripState = LED_STRIP_MODE_UNKNOWN;
}

CLedStrip::CLedStrip(const CLedStrip& orig)
{
    m_ledStripState = orig.m_ledStripState;
}

CLedStrip::~CLedStrip()
{
}

bool CLedStrip::isValid() const
{
    if ((((int) m_ledStripState) > 0)
            && (((int) m_ledStripState) < NUMBER_OF_LED_STRIP_MODES))
    {
        return true;
    }
    return false;
}

std::string CLedStrip::displayText() const
{
    char buf [64];
    std::string sRet = "0";
    if (isValid())
    {
        sprintf(buf, "%d", m_ledStripState);
        sRet = buf;
    }
    return sRet;
}

void CLedStrip::setMode(CLedStrip::LED_STRIP_MODE mode)
{
    switch (mode)
    {
    case CLedStrip::LED_STRIP_OFF:
        // TODO:
        m_ledStripState = CLedStrip::LED_STRIP_OFF;
        break;

    case CLedStrip::LED_STRIP_NORMAL:
        // TODO:
        m_ledStripState = CLedStrip::LED_STRIP_NORMAL;
        break;

    case CLedStrip::LED_STRIP_COLLECTING:
        // TODO:
        m_ledStripState = CLedStrip::LED_STRIP_COLLECTING;
        break;

    case CLedStrip::LED_STRIP_GOT_BALL:
        // TODO:
        m_ledStripState = CLedStrip::LED_STRIP_GOT_BALL;
        break;

    case CLedStrip::LED_STRIP_SHOOTING:
        // TODO:
        m_ledStripState = CLedStrip::LED_STRIP_SHOOTING;
        break;

    default:
    case CLedStrip::LED_STRIP_MODE_UNKNOWN:
        dbgMsg_d1("CLedStrip received an unrecognized command = %d\n", (int) mode);
        break;
    }
}

